/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package generator.connection;

import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;

public class CustomComboBoxModel<T> implements ComboBoxModel<T> {

    public T selectedElement;
    public T [] items;
    
    public CustomComboBoxModel(T[] items) {
        this.items = items;
    }
    
    @Override
    public Object getSelectedItem() {
        return selectedElement;
    }
    
    @Override
    public int getSize() {
        return items!=null ? items.length : 0;
    }
    
    @Override
    public T getElementAt(int index) {
        return items!=null ? items[index] : null;
    }

    @Override
    public void setSelectedItem(Object anItem) {
         selectedElement = (T) anItem;
    }
    
    ////////////////////////////////////////////////////////////////////////////
    //
    ////////////////////////////////////////////////////////////////////////////
     @Override
    public void addListDataListener(ListDataListener l) {
        
    }
    
    @Override
    public void removeListDataListener(ListDataListener l) {
       
    }
    
}